// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Sabotage an object
// -----------------------------------------------

private ["_unit","_missioncomplete","_typeof","_position"];

_unit   = _this select 0;
_typeof = _this select 1;

_position = position _unit;

//A3 TODO: setVehicleInit
_unit setVariable ["wcbuild", false, true];
_unit setVehicleInit "this addAction ['<t color=''#ff4500''>Build</t>', 'warcontext\actions\WC_fnc_dobuild.sqf', [], 6, false];";
processInitCommands;

_missioncomplete = false;

while {!_missioncomplete} do {
	if (_unit getVariable "wcbuild") then {
		deleteVehicle _unit;
		_unit = _typeof createVehicle _position;
		_unit setPos _position;
		wcmessageW = [localize "STR_WC_MESSAGEMISSIONCOMPLETED", localize "STR_WC_MESSAGELEAVEZONE"];
		["wcmessageW", "client"] call WC_fnc_publicvariable;
		wcmissionsuccess = true;
		_missioncomplete = true;
		wcleveltoadd = 1;
		wcfame = wcfame + wcbonusfame;
		wcenemyglobalelectrical = wcenemyglobalelectrical + wcbonuselectrical;
		wcenemyglobalfuel = wcenemyglobalfuel + wcbonusfuel;
	};
	sleep 1;
};